<section class="slider">
    <div class="flexslider">
        <ul class="slides">
    

            <?php
            $slider = Yii::app()->cache->get('slider');
            if ($slider === FALSE) {
                $slider = Slider::model()->findAll(array(
                    'condition' => 'flag=1 and id<>93 ',
                    'order' => 'RAND()',
                    'limit' => 30,
                ));
                Yii::app()->cache->set('slider', $slider, 3600);
            }
            echo 'Đang tải dữ liệu ...';

            if (!empty($slider)) {
                foreach ($slider as $item) {
                    if ($item->type < 1) {
                        ?>
                        <li>
                            <a href="<?php echo $item->url ?>" target="_blank">
                                <div class="slider_letf">
                                    <img src="<?php echo Yii::app()->request->baseUrl . '/upload/product/slider/' . $item->photo; ?>" width="448" height="340" />
                                </div>
                                <div class="slider_right">
                                    <div class="content_slide">
                                        <div class="title_slide">
                                            <?php echo $item->title ?>
                                        </div>
                                        <p>
                                            <?php echo $item->small_content ?>
                                        </p>
                                    </div>

                                </div>
                            </a>
                        </li>
                        <?php
                    } else {
                        ?>
                        <li>

                            <div class="slider_letf">
                                <?php echo $item->url; ?>
                            </div>
                            <div class="slider_right">
                                <div class="content_slide">
                                    <div class="title_slide">
                                        <?php echo $item->title ?>
                                    </div>
                                    <p>
                                        <?php echo $item->small_content ?>
                                    </p>
                                </div>

                            </div>

                        </li>
                        <?php
                    }
                }
            }
            ?>
        


        </ul>
    </div>
</section>


<script defer src="<?php echo Yii::app()->request->baseUrl; ?>/js/flexslider/jquery.flexslider.js"></script>

<script type="text/javascript">
    // Can also be used with $(document).ready()
    $(window).load(function() {

        // Vimeo API nonsense
        //var player = document.getElementById('player_1');
        //$f(player).addEvent('ready', ready);

        function addEvent(element, eventName, callback) {
            if (element.addEventListener) {
                element.addEventListener(eventName, callback, false)
            } else {
                element.attachEvent(eventName, callback, false);
            }
        }

        function ready(player_id) {
            var froogaloop = $f(player_id);
            froogaloop.addEvent('play', function(data) {
                $('.flexslider').flexslider("pause");
            });
            froogaloop.addEvent('pause', function(data) {
                $('.flexslider').flexslider("play");
            });
        }


        // Call fitVid before FlexSlider initializes, so the proper initial height can be retrieved.
        $(".flexslider")
                .fitVids()
                .flexslider({
                    animation: "slide",
                    useCSS: false,
                    animationLoop: false,
                    smoothHeight: true,
                   // before: function(slider) {
                       // $f(player).api('pause');
                   // }
                });
    });
</script>

<!-- Syntax Highlighter -->
<script type="text/javascript" src="<?php echo Yii::app()->request->baseUrl; ?>/js/flexslider/shCore.js"></script>
<script type="text/javascript" src="<?php echo Yii::app()->request->baseUrl; ?>/js/flexslider/shBrushXml.js"></script>
<script type="text/javascript" src="<?php echo Yii::app()->request->baseUrl; ?>/js/flexslider/shBrushJScript.js"></script>

<!-- Optional FlexSlider Additions -->
<script src="<?php echo Yii::app()->request->baseUrl; ?>/js/flexslider/froogaloop.js"></script>
<script src="<?php echo Yii::app()->request->baseUrl; ?>/js/flexslider/jquery.fitvid.js"></script>
<script src="<?php echo Yii::app()->request->baseUrl; ?>/js/flexslider/demo.js"></script>